<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>Bruger</title>
    <link rel="stylesheet" type="text/css" href="../CSS/CSS.css" />
    <link rel="stylesheet" type="text/css" href="../CSS/header.css" />
    <script src="http://code.jquery.com/jquery-latest.min.js"></script>
    <script>
    if (!window.jQuery) {
        document.write('<script src="../Javascript/jQuery.js"><\/script>');
    }
    </script>
    <script src="../Javascript/Popups.js"></script>  
    <meta name="viewport" content="width=device-width; initial-scale=1.0">
    <?php
        include_once 'session_start.php';
        include_once 'session_check.php';
        if($_SESSION["User"]["Id"]==$_GET["id"]){
            goto ad_skip;
        }
        include_once 'admin_check.php';
        ad_skip:
        include_once 'database.php';
    ?>
</head>
<body>
<?php include_once 'header.php' ?>
<div id="page_content">
	<?php        
	    $query = "SELECT username,FirstName,LastName,Email,Address,Country,PostalCode FROM users WHERE UserId =".$_GET["id"];   
	    $stmt = $db -> prepare($query);
	    $stmt -> execute();
	    $stmt -> bind_result($username,$f_name,$l_name,$email,$address,$country,$postcode);
	    $stmt -> fetch();
	?>
	<h1>Bruger</h1>
	<?php include_once "get_message.php" ?>
	<form action="update_user_db.php?id=<?php echo $_GET['id'];?>&change=info" method="post">
	    <table>
	        <tr>
	            <td><b>Brugernavn:</b></td>
	            <td><?php echo $username ?></td>
	        </tr>
	        <tr>
	            <td><b>Fornavn:</b></td>
	            <td><input type="text" name="F_Name"  value="<?php echo $f_name ?>"/></td>
	        </tr>
	        <tr>
	            <td><b>Efternavn:</b></td>
	            <td><input type="text" name="L_Name"  value="<?php echo $l_name ?>"/></td>
	        </tr>
	        <tr>
	            <td><b>E-mail:</b></td>
	            <td><input type="text" name="E-mail"  value="<?php echo $email ?>"/></td>
	        </tr>
	        <tr>
	            <td><b>Adresse:</b></td>
	            <td><input type="text" name="Address"  value="<?php echo $address ?>"/></td>
	        </tr>
	        <tr>
	            <td><b>Land:</b></td>
	            <td>
	                <select name="Country">
	                    <?php include 'country_dropdown.html'?>
	                </select>
	           </td>
	        </tr>
	        <tr>
	            <td><b>Post nr: </b></td>
	            <td><input type="text" name="Postal_Code"  value="<?php echo $postcode ?>"/></td>
	        </tr>
	    </table>
	<button>Opdater person oplysninger</button>
	</form>
	<?php
	    if(!isset($_GET["pass"])){
	        echo '<a href="user.php?id='.$_GET["id"].'&pass=change">Skift password</a>';   
	    }else{
	        echo'<form action="update_user_db.php?id='.$_GET["id"].'&change=pass" method="post"><br>
	                <table>
	                    <tr>
	                        <td>
	                            <b>Gamle password:</b>
	                        </td>
	                        <td>
	                            <input type="password" name="old_pass">
	                        </td>
	                    </tr>
	                    <tr>
	                        <td>
	                            <b>Nye password:</b>
	                        </td>
	                        <td>
	                            <input type="password" name="new_pass">
	                        </td>
	                    </tr>
	                    <tr>
	                        <td>
	                            <b>Bekræft password:</b>
	                        </td>
	                        <td>
	                            <input type="password" name="cf_pass">
	                        </td>
	                    </tr>
	                    <tr>
	                        <td><button>Skift password</button></td>
	                    </tr>
	                </table>
	            </form>';
	    }
	?>
</div>	
<?php include_once 'footer.php' ?>
</body>
</html>



















